package cqie.personal.frame.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

@Data
public class MenuView {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    private String menuName;
    private String menuAddress;
    private Integer menuLevel;
    private Integer menuFather;
    private List<MenuView> childList;

    public void setChild(MenuView menu  ,List<MenuView> all){
        List<MenuView> child = all.stream()
                .filter(x->x.getMenuFather()!=null&&x.getMenuFather().equals(menu.getId()))
                .collect(Collectors.toList());
        menu.setChildList(child);
        for (MenuView menuTree : child) {
            setChild(menuTree, all);
        }
    }
}
